import {createFromIconfontCN} from '@ant-design/icons';
import {IconFontProps} from "@ant-design/icons/es/components/IconFont";
import React from "react";

let IconFont: React.FC<IconFontProps<string>>;

export const GIcon = (props: any) => {

  if (!IconFont) {
    let iconScriptUrlData = localStorage.getItem('IconScriptUrl');
    if (!iconScriptUrlData) {
      iconScriptUrlData = '["//at.alicdn.com/t/c/font_2379370_2wvgw9oedx2.js"]';
    }
    const iconScriptUrl = JSON.parse(iconScriptUrlData);
    IconFont = createFromIconfontCN({
      scriptUrl: iconScriptUrl,
    });
  }

  return <IconFont {...props} />;
};
